package com.springsessiondemo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class DemoController {

    private String key="mykey";
    @GetMapping("setSession")
    public void setSession(HttpSession session, String value){
        session.setAttribute(key,value);
    }

    @GetMapping("getSession")
    public String getSession(HttpSession session){
        return (String) session.getAttribute(key);
    }
}
